using Quartz;
using Quartz.Spi;

namespace PHMEE.VibrationDataGenerator.Services;

public class VibDataGeneratorTaskJobFactory : IJobFactory
{
    private readonly IServiceProvider _serviceProvider;

    public VibDataGeneratorTaskJobFactory(IServiceProvider serviceProvider)
    {
        _serviceProvider = serviceProvider;
    }
    
    public IJob NewJob(TriggerFiredBundle bundle, IScheduler scheduler)
    {
        // 使用 DI 容器创建 Job 实例
        return _serviceProvider.GetRequiredService(bundle.JobDetail.JobType) as IJob ?? throw new Exception("Could not instantiate job");
    }

    public void ReturnJob(IJob job)
    {
        
    }
}